
const path = require('path');

const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    mode: 'production',
    entry: path.join(__dirname, 'server.ts'),
    module: {
        rules: [
            {
                test: /\.ts$/,
                use: {
                    loader: 'ts-loader'
                },
                exclude: /node_modules/
            }
        ]
    },
    resolve: {
        extensions: ['.ts', '.js']
    },
    target: 'node',

    plugins: [
        new CopyWebpackPlugin({
            patterns: [{
                from: path.join(__dirname, 'public'),
                to: path.join(__dirname, 'dist', 'public')
            }, {
                from: path.join(__dirname, 'package.json'),
                to: path.join(__dirname, 'dist', 'package.json')
            },
            {
                from: path.join(__dirname, 'package-lock.json'),
                to: path.join(__dirname, 'dist', 'package-lock.json')
            }]
        })
    ]
}